<?php include("header.php"); ?>
<script type="text/javascript" src="<?php echo APPLICATION_URL ?>/public/js/jquery-ui-1.8.16.custom.min.js"></script>
<link type="text/css" href="<?php echo APPLICATION_URL ?>/public/js/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo APPLICATION_URL ?>/public/js/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.js"></script>

<script type="text/javascript">
    function validate()
	{
        var name = document.getElementById('ship_name');
		var country = document.getElementById('country');
        var grt = document.getElementById('grt');
        var dwt = document.getElementById('dwt');
        var date_time = document.getElementById('date_time');
        var arriving_port = document.getElementById('arriving_port');
        var leaving_port = document.getElementById('leaving_port');
        var goods = document.getElementById('goods');
        var draf = document.getElementById('draf');
        var loa = document.getElementById('loa');
        var region = document.getElementById('region');
        
        if(isEmptyTextBox(name, '<?php echo _MSG_SHIP_NAME_NOT_EMPTY; ?>'))
        {
            return false;
        }

        if(isEmptyTextBox(country, '<?php echo _MSG_COUNTRY_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if(isEmptyTextBox(grt, '<?php echo _MSG_GRT_NOT_EMPTY; ?>'))
        {
            return false;
        } else {
            if (isNaN(grt.value)) {
                showErrorBubble(grt, '<?php echo _MSG_GRT_INVALID; ?>');
                return false;
            }
        }
        
        if(isEmptyTextBox(dwt, '<?php echo _MSG_DWT_NOT_EMPTY; ?>'))
        {
            return false;
        } else {
            if (isNaN(dwt.value)) {
                showErrorBubble(dwt, '<?php echo _MSG_DWT_INVALID; ?>');
                return false;
            }
        }
        
        if(isEmptyTextBox(leaving_port, '<?php echo _MSG_LEAVING_PORT_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if(isEmptyTextBox(arriving_port, '<?php echo _MSG_ARRIVING_PORT_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if (leaving_port.value == arriving_port.value) {
            showErrorBubble(grt, '<?php echo _MSG_ARRVING_LEAVING_PORT_INVALID; ?>');
            return false;
        }
        
        if(isEmptyTextBox(date_time, '<?php echo _MSG_DATE_TIME_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if(isEmptyTextBox(draf, '<?php echo _MSG_DRAF_NOT_EMPTY; ?>'))
        {
            return false;
        }
        if(isEmptyTextBox(loa, '<?php echo _MSG_LOA_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if(isEmptyTextBox(goods, '<?php echo _MSG_GOODS_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if(isEmptyTextBox(region, '<?php echo _MSG_REGION_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
		document.ship_schedule.submit();
	}

    $(document).ready(function() {
         $('#date_time').datetimepicker({
            dateFormat: "dd/mm/yy",
            stepMinute: 5
        });
        
    });
</script>

	<div class="one_center">
		<div class="box_two_third">
			<div class="box_head"><?php if($ship_schedule->id) { echo _LB_EDIT_SHIP_SCHEDULE_ARRIVING; } else { echo _LB_ADD_SHIP_SCHEDULE_ARRIVING; } ?></div>
			<div class="box_content" >
				<form action="" name="ship_schedule" method="post">
				<input type="hidden" id="id" name="id" value="<?php $ship_schedule->id; ?>"/>
				<input type="hidden" id="act" name="act" value="<?php echo ACT_VALID_EDIT; ?>"/>
				<table cellpadding="0" cellspacing="5px" border="0">
                    <tr>
						<td width="20%"><label><?php echo _LB_SHIP_NAME; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="ship_name" id="ship_name" type="text" size="<?php echo SIZE_NAME; ?>" maxlength="<?php echo MAX_LENGTH_NAME;?>" value="<?php echo $ship_schedule->ship_name; ?>"/></td>
					</tr>
					<tr>
                        <td width="20%"><?php echo _LB_NATIONALITY; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></td>
                        <td>
                            <select id="country" name="country" style="width: 180px;">
                                <option value=""><?php echo _LB_CHOOSE; ?></option>
                                <?php while($country->fetchNext()) { ?>
                                   <option value="<?php echo $country->id; ?>" <?php if($country->id == $ship_schedule->id_wp_country) {?>selected="true"<?php }?>><?php echo $country->name; ?></option>
                                <?php } ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_GRT; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="grt" id="grt" type="text" size="<?php echo SIZE_NAME; ?>" maxlength="<?php echo MAX_LENGTH_NAME;?>" value="<?php echo $ship_schedule->grt; ?>"/></td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_DWT; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="dwt" id="dwt" type="text" size="<?php echo SIZE_NAME; ?>" maxlength="<?php echo MAX_LENGTH_NAME;?>" value="<?php echo $ship_schedule->dwt; ?>"/></td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_SHIP_LEAVING; ?>&nbsp;:&nbsp;</label></td>
                        <td>
                            <select id="leaving_port" name="leaving_port" style="width: 180px;">
                                <?php while($port->fetchNext()) { ?>
                                <option value="<?php echo $port->id; ?>" <?php if($port->id == $ship_schedule->leaving_port) {?>selected="true"<?php }?>><?php echo $port->name; ?></option>
                                <?php } ?>
                            </select>
                        </td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_SHIP_ARRIVING; ?>&nbsp;:&nbsp;</label></td>
                        <td>
                            <select id="arriving_port" name="arriving_port" style="width: 180px;">
                                <?php while($port2->fetchNext()) { ?>
                                <option value="<?php echo $port2->id; ?>" <?php if($port2->id == $ship_schedule->arriving_port) {?>selected="true"<?php }?>><?php echo $port2->name; ?></option>
                                <?php } ?>
                            </select>
                        </td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_DATE_TIME; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="date_time" class="inputbox smallbox" id="date_time" type="text" size="<?php echo SIZE_NAME; ?>" value="<?php echo date_sql_to_date($ship_schedule->date_time); ?>"/>
                            <br>
                        <span class="smltxt">(Kiểu: ngày / tháng / năm&nbsp;&nbsp;giờ : phút : giây)</span>
                        </td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_DRAF; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="draf" id="draf" type="text" size="<?php echo SIZE_NAME; ?>" maxlength="<?php echo MAX_LENGTH_NAME;?>" value="<?php echo $ship_schedule->draf; ?>"/></td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_LOA; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="loa" id="loa" type="text" size="<?php echo SIZE_NAME; ?>" maxlength="<?php echo MAX_LENGTH_NAME;?>" value="<?php echo $ship_schedule->loa; ?>"/></td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_ADVERTISER; ?>&nbsp;:&nbsp;</label></td>
                        <td><textarea name="advertiser" id="advertiser" cols="36" rows="4" ><?php echo $ship_schedule->advertiser; ?></textarea></td>
					</tr>
                    <tr>
						<td width="20%"><label><?php echo _LB_GOODS; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><textarea name="goods" id="goods" cols="36" rows="4" ><?php echo $ship_schedule->goods; ?></textarea></td>
					</tr>
                    <tr>
                        <td width="20%"><?php echo _LB_REGION; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></td>
                        <td id="reg">
                            <select id="region" name="region" style="width: 180px;">
                                <option value=""><?php echo _LB_CHOOSE; ?></option>
                                <?php while($region->fetchNext()) { ?>
                                   <option value="<?php echo $region->id; ?>" <?php if($region->id == $ship_schedule->id_wp_region) {?>selected="true"<?php }?>><?php echo $region->name; ?></option>
                                <?php } ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
					  	<td class="submit" colspan="2" style="padding-top: 10px;">
							  <a id="auto_ship_schedule_return" class="tribullet" id="btnReturn" href="<?php echo $backlink; ?>"><?php echo _LB_BACK; ?></a>
							  <a id="auto_ship_schedule_validate" class="tribullet" href="#" onclick="validate()"><?php echo _LB_VALIDATE; ?></a>
						</td>
					</tr>
				</table>
				</form>
			</div>
		</div>
	</div>

<?php include("footer.php"); ?>

